/*
 * elasticforceextractor.h
 *
 *      Author: Jerome RD Soine and Christoph A Brand
 *      Institution: Schwarz goup, Institute for Theoretical Physics, Heidelberg University, Germany
 */

#ifndef ELASTICFORCEEXTRACTOR_H_
#define ELASTICFORCEEXTRACTOR_H_

#include "energycolordataextractor.h"

class ElasticForceExtractor : public EnergyColorDataExtractor {
private:
	ElasticEnergy * e;
public:
	ElasticForceExtractor(ElasticEnergy * elasticEnergy, ColorDataExtractor * additional = NULL) : EnergyColorDataExtractor(elasticEnergy, additional){
		e = elasticEnergy;
	}

	void writeEdgesColorToFile(ofstream & fout){
		vector<Edge*> edges = *g->getEdges();
		for(unsigned int i=0; i<edges.size(); i++){
			double force = e->getForceOfEdge(edges[i]);
			fout << force << endl;
		}
	}

	void writeFillColors(ofstream & fout){
		int numberOfTriangles = g->getTriangles()->size();
		for(int i=0; i<numberOfTriangles; i++){
			fout << 0 << endl;
		}
	}

	void writeToFile(ofstream & fout){
		fout << "SCALARS elastic_force_scalars double 1" << endl << "LOOKUP_TABLE default" << endl;
		writeEdgesColorToFile(fout);
		writeFillColors(fout);
		fout << endl;
	}
};


#endif /* ELASTICFORCEEXTRACTOR_H_ */
